﻿using Microsoft.AspNetCore.Mvc;
using EasyIot.Model;
using EasyIot.Service;
using EasyIot.WebApp.Controllers;

namespace EasyIot.WebApp.Areas.Security.Controllers
{
    public class LogonLogController : BaseController
    { 
        // GET: Security/LogonLog
        public override ActionResult Index(int? id)
        {
            base.Index(id);
            return View();
        }

        [HttpGet]
        public JsonResult List(LogonLogModel model, PageInfo pageInfo)
        {
            var result = LogonLogService.GetListByFilter(model, pageInfo);
            return Json(result);
        }

        [HttpGet]
        public JsonResult Delete(int id)
        {
            var result = LogonLogService.DeleteById(id) ? SuccessTip("删除成功") : ErrorTip("删除失败");
            return Json(result);
        }

        [HttpGet]
        public JsonResult BatchDel(string idsStr)
        {
            var idsArray = idsStr.Substring(0, idsStr.Length - 1).Split(',');
            var result = LogonLogService.DeleteByIds(idsArray) ? SuccessTip("批量删除成功") : ErrorTip("批量删除失败");
            return Json(result);
        }
    }
}